package gui.JPanels;

import gui.GLJPanels.GLJPanelCurvas;
import gui.GLListeners.GLListener;
import gui.GLListeners.GLListenerCurvas;
import gui.GLListeners.GLReceptaculos.GLListenerReceptaculoCircules;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

import utils.files.FileManagerFlowers;
import camaras.Camara;

public abstract class JPanelCurvas extends JPanel{
	protected GLListener GLL;
	protected GLJPanelCurvas canvas;
	
	public JPanelCurvas() {
		super();
	}

	protected void initComponents() {

        JButton button_3d = new JButton("3D");
        button_3d.addActionListener(new Bt_3d_Listener());
        this.add(button_3d,BorderLayout.EAST);
        
        JButton button_clear = new JButton("Nuevo");
        button_clear.addActionListener(new Bt_clear_Listener());
        this.add(button_clear,BorderLayout.WEST);	

	}

	protected class Bt_3d_Listener implements ActionListener{
		public void actionPerformed(ActionEvent e){
			canvas.getContext().makeCurrent();
			((GLListenerCurvas)GLL).setCamaraPosicion(Camara.ESQUINA);
			canvas.repaint();
			canvas.requestFocus();
		}
	}
	
	protected class Bt_clear_Listener implements ActionListener{
		public void actionPerformed(ActionEvent e){
			FileManagerFlowers.setReceptacle(null);
			canvas.getContext().makeCurrent();
			((GLListenerCurvas)GLL).limpiaCurvas();
			if(GLL instanceof GLListenerReceptaculoCircules){
				((GLListenerReceptaculoCircules)GLL).creaReceptaculoTemp();
				((GLListenerReceptaculoCircules)GLL).setCamaraPosicion(Camara.FRONTAL);
			}
			
			canvas.repaint();
			canvas.requestFocus();
		}
	}
}



